﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERPStore.NewsLetters.MessageReaders
{
	public class ScheduleNewsLettersCampaignMessageReader : Ariane.MessageReaderBase<Models.ScheduleCampaignQueueMessage>
	{
		public ScheduleNewsLettersCampaignMessageReader(Services.NewsLettersService newsLettersService
			, ERPStore.Logging.ILogger logger)
		{
			this.NewsLettersService = newsLettersService;
			this.Logger = logger;
		}

		protected Services.NewsLettersService NewsLettersService { get; set; }
		protected ERPStore.Logging.ILogger Logger { get; private set; }

		public override void ProcessMessage(Models.ScheduleCampaignQueueMessage message)
		{
			Logger.Info("Receive request start campaign {0} at {1}", message.CampaignId, message.ScheduledDate);
			NewsLettersService.ScheduleCampaign(message.CampaignId, message.ScheduledDate);
		}
	}
}
